package com.ge.modules.base.controller;

import com.ge.common.utils.R;
import com.ge.modules.base.service.TbCityService;
import com.ge.modules.entity.TbCityEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 市
 *
 * @author Luo
 * @email www.baidu.com
 * @date 2018-04-12 09:56:17
 */
@RestController
@RequestMapping("/loca/city")
public class TbCityController {

    @Autowired
    private TbCityService tbCityService;

    /**
     * 根据省份id来查所有城市
     */
    @RequestMapping("/list")
    public R list(@RequestParam("provinceid") int provinceid) {
        List<TbCityEntity> cityList = tbCityService.getList(provinceid);
        return R.ok().put("cityList", cityList);
    }

    /**
     * 根据城市id来查询城市
     */
    @RequestMapping("/info/{cityid}")
    public R info(@PathVariable("cityid") Integer cityid) {
        TbCityEntity city = tbCityService.queryObject(cityid);
        return R.ok().put("city", city);
    }


}
